# Maintainer: Ignacio Casal Quinteiro <icq@gnome.org>

_realname=libgit2-glib
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.24.0
pkgrel=1
arch=('any')
pkgdesc="A glib wrapper library around the libgit2 git access library (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-libgit2>=0.23"
         "${MINGW_PACKAGE_PREFIX}-glib2")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "${MINGW_PACKAGE_PREFIX}-python3"
             "${MINGW_PACKAGE_PREFIX}-vala"
             "gtk-doc")
options=('strip' 'staticlibs')
license=("LGPL")
url="https://wiki.gnome.org/Projects/Libgit2-glib"
source=("https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}-${pkgver}.tar.xz")
sha256sums=('d616c268821c28ff8dc1a6419dbf8555fa48e31dc6509c10f5151be7690f4845')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}

  autoreconf -f -i
}

build() {
  mkdir -p build-${MINGW_CHOST}
  cd build-${MINGW_CHOST}

  mkdir -p docs/reference/html
  cp -rf ../${_realname}-${pkgver}/docs/reference/html/* docs/reference/html

  export PYTHON=${MINGW_PREFIX}/bin/python3
  ../${_realname}-${pkgver}/configure \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib \
    --enable-python

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR=${pkgdir} install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
